#!/usr/bin/env bash

BUILD_PATH="/opt/we/we_server"
WORK_PATH="/www/wwwroot/we/service"
echo ==============================
echo   we 升级脚本启动
echo ==============================

cd ${BUILD_PATH}

echo 开始 pull 代码

git pull

echo 获取代码完成

echo 开始编译代码

mvn clean package -Dmaven.test.skip=true -Pdev

echo 编译完成

echo 重命名

mv ${BUILD_PATH}/target/we_server-*.jar we_server.jar

echo 备份原jar包
rm ${WORK_PATH}/we_server.jar.bak
mv ${WORK_PATH}/we_server.jar ${WORK_PATH}/we_server.jar.bak

echo 覆盖jar包
mv ${BUILD_PATH}/target/we_server.jar ${WORK_PATH}/we_server.jar

echo 重启服务

systemctl restart we
systemctl status we
echo 完成
